Completed
Branch master (ebb499)
by Alexey
04:15
created

inji.onLoad   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A 0 10 1
1
/**
2
 * Item name
3
 *
4
 * Info
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
inji.Notifications = {
12
  showNotification: function (title, text, action) {
13
    var notification = new Notification(title, {
14
      icon: '/static/system/images/logo-dark.png',
15
      body: text,
16
    });
17
    if (action) {
18
      notification.onclick = action;
19
    }
20
  }
21
}
22
inji.onLoad(function () {
23
  setInterval(function () {
24
    inji.Server.request({
25
      url: '/notifications/check',
26
      success: function (result) {
27
        for (var key in result) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
28
          inji.Notifications.showNotification(result[key].notification_name, result[key].notification_text);
29
        }
30
      }
31
    });
32
  }, 30 * 1000);
33
})